import * as types from "../types/bindMobileTypes";

const initialState = {
  loading: false,
  error: undefined,
  mobile: "",
};

export default function bindMobileGetCodeReducer(state = initialState, action) {
  switch (action.type) {
    case types.BINDMOBILE_GETCODE_LOADING:
      return {
        ...state,
        loading: true,
      };
    case types.BINDMOBILE_GETCODE_DONE:
      return {
        ...state,
        loading: false,
      };
    case types.BINDMOBILE_GETCODE_ERROR:
      return {
        ...state,
        loading: false,
        error: action.error,
      };
    case types.BINDMOBILE_INPUTMOBILE:
      return {
        ...state,
        mobile: action.mobile,
      };
    case types.BINDMOBILE_GETCODEUNMOUNT:
      return {
        ...initialState,
      };
    default:
      return state;
  }
}
